using System;
using Serpis;

namespace PVenta
{
	[ValidatorView]
	public partial class ArticuloView : Gtk.Window, IEntityView
	{
	public ArticuloView () : base(Gtk.WindowType.Toplevel)
		{
			this.Build ();
			precio.Adjustment.Lower = int.MinValue;
			precio.Adjustment.Upper = int.MaxValue;
			precio.Digits = 2;
			
			
			categoria.Init(typeof(Categoria), "from Categoria");
			categoria.Id = null;
		}
		
		[ModelProperty]
		public string Nombre {
			get {return nombre.Text;}
			set {nombre.Text = value ?? "";}
		}
		
		[ModelProperty]
		public decimal Precio {
			get {return Convert.ToDecimal(precio.Value);}
			set {precio.Value = Convert.ToDouble(value);}
		}
		
		[ModelProperty]
		public object Categoria {
			get {return categoria.Id;}
			set {categoria.Id = value;}
		}
		
		public Gtk.Action SaveAction {
			get {return saveAction;}
		}
	}
}

